package Txtfiction;

import java.beans.XMLEncoder;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

public class test {
    public static void main(String[] args) {
        //初始化数据
        List<User> list=new ArrayList<>();
        list.add(new User("zzz","123456","123456"));
        list.add(new User("www","123456","123456"));
        XMLEncoder xec= null;
        try {
            xec = new XMLEncoder(new FileOutputStream("D:\\76班java workspace\\Y2Java项目\\JavaSenior\\src\\Txtfiction\\user1.xml"));
            xec.writeObject(list);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }finally {
            xec.close();
        }
    }
}
